package com.indexingsystem.system.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.indexingsystem.boss.Vo.ResourceRelationsVo;
import com.indexingsystem.boss.Vo.ResourcesVo;
import com.indexingsystem.boss.admin.mapper.ResourceRelationsMapper;
import com.indexingsystem.boss.common.PagedResult;
import com.indexingsystem.boss.entity.ResourceRelations;
import com.indexingsystem.boss.utils.StringUtil;
import com.indexingsystem.system.service.IResourceRelationsService;


@Service
public class ResourceRelationsServiceImpl implements IResourceRelationsService {
	
	@Resource
	private ResourceRelationsMapper resourceRelationsMapper;

	@Override
	public int deleteByPrimaryKey(String resRelationId) {
		return resourceRelationsMapper.deleteByPrimaryKey(resRelationId);
	}

	@Override
	public int insertSelective(ResourceRelations record) {
		return resourceRelationsMapper.insertSelective(record);
	}

	@Override
	public ResourceRelations selectByPrimaryKey(String resRelationId) {
		return resourceRelationsMapper.selectByPrimaryKey(resRelationId);
	}

	@Override
	public int updateByPrimaryKeySelective(ResourceRelations record) {
		return resourceRelationsMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public PagedResult<ResourceRelationsVo> selectResourceRelationsList(ResourceRelationsVo ResourceRelationsVo) {
		return null;
	}

	@Override
	public PagedResult<ResourceRelationsVo> selectResourceRelationsList(Integer pageNo, Integer pageSize) {
		return null;
	}

	@Override
	public Integer getResourceRelationsListCount(ResourceRelationsVo resourceRelationsVo) {
		return null;
	}

	@Override
	public Integer addResourceRelations(ResourcesVo firstVo, ResourcesVo secondVo)throws Exception {
		ResourceRelations resourceRelations = new ResourceRelations();
		//封装数据
		resourceRelations.setResRelationId(StringUtil.createSystemDataPrimaryKey());
		resourceRelations.setFristResId(firstVo.getResId());
		resourceRelations.setSecondResId(secondVo.getResId());
		resourceRelations.setRelationType(1);
		return resourceRelationsMapper.insertSelective(resourceRelations);
	}

	@Override
	public Integer removeResourceRelations(ResourceRelationsVo record) {
		return resourceRelationsMapper.deleteByPrimaryKey(record.getResRelationId());
	}
	
	
	   /**
     * 通过资源id获取资源关系所有记录.
     * @param resId
     * @return
     */
	@Override
    public List<ResourceRelations> getResourceRelationsListByResId(String resId){
        return resourceRelationsMapper.getResourceRelationsListByResId(resId);
    }
}